package com.qu.Media.media.util;

import com.bumptech.glide.load.model.GlideUrl;

import java.util.concurrent.Executor;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

/**
 * 开启线程池
 * Created by quguangle on 2017/4/18.
 */

public class AppOperator {
    private static ExecutorService EXECUTORS_INSTANCE;

    public static Executor getExecutor() {
        if (EXECUTORS_INSTANCE == null) {
            synchronized (AppOperator.class) {
                if (EXECUTORS_INSTANCE == null) {
                    EXECUTORS_INSTANCE = Executors.newFixedThreadPool(6);
                }
            }
        }
        return EXECUTORS_INSTANCE;
    }
    public static GlideUrl getGlideUrlByUser(String url) {
       /* if (AccountHelper.isLogin()) {
            return new GlideUrl(url,
                    new LazyHeaders
                            .Builder()
                            .addHeader("Cookie", AccountHelper.getCookie())
                            .build());
        } else {
            return new GlideUrl(url);
        }*/
        return new GlideUrl(url);
    }
    public static void runOnThread(Runnable runnable) {
        getExecutor().execute(runnable);
    }

}
